package com.myblog.adkblog.controller;

import com.myblog.adkblog.utils.SseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import reactor.core.publisher.Flux;

import java.time.Duration;
import java.time.LocalTime;

/**
 * 日期: 2024年11月10日
 * 时间: 10:36
 * 作者: XinForever
 */
@RestController
@RequestMapping("/sse")
public class SseController {

    @Autowired
    private SseUtil ssseUtil;

    @GetMapping(value = "/{clientId}", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public SseEmitter streamEvents(@PathVariable("clientId") String clientId) {
        return ssseUtil.createSseEmitter(clientId);
    }

}
